//
//  AboutProduct_ViewController.m
//  International_Hospital
//
//  Created by LiYiLin on 16/7/4.
//  Copyright © 2016年 LiYiLin. All rights reserved.
//

#import "AboutProduct_ViewController.h"
#import <SVProgressHUD.h>

@interface AboutProduct_ViewController ()<UITableViewDataSource,UITableViewDelegate>

//中间图片
@property (nonatomic, strong)UIImageView *centerImage;
//中间图片名称
@property (nonatomic, strong)UIImageView *nameImage;

@property (nonatomic, weak)UILabel *messageLabel;

@property (nonatomic, weak)UILabel *versionlabel;

@end

@implementation AboutProduct_ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置并添加子控件
    [self setupUI];
    
}

#pragma mark
#pragma mark - 设置并添加子控件
- (void)setupUI{
    
    self.view.backgroundColor = [UIColor whiteColor];
    //创建
    UITableView *tableView = [[UITableView alloc] init];
    //设置代理,数据源
    tableView.dataSource = self;
    tableView.delegate = self;
    //添加
    [self.view addSubview:tableView];
    //设置约束
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.leading.trailing.bottom.equalTo(self.view);
        
    }];
    
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
    //设置组头
    UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 250)];
    tableView.tableHeaderView = headView;
    //设置组尾
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-500)];
    tableView.tableFooterView = footerView;
    
    UILabel *message = [[UILabel alloc] init];
    message.text = @"用户交流: 45678888";
    message.textColor = [UIColor colorWithRed:63/255.0 green:167/255.0 blue:226/255.0 alpha:1];
    message.font = [UIFont systemFontOfSize:20];
    self.messageLabel = message;
    
    UILabel *versions = [[UILabel alloc] init];
    versions.text = @"version:1.4.0";
    versions.textColor = [UIColor colorWithRed:63/255.0 green:167/255.0 blue:226/255.0 alpha:1];
    self.versionlabel = versions;

    self.centerImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"product_img_logo_nor.png"]];
    self.nameImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"product_text_logo_nor.png"]];
    
    //添加控件
    [headView addSubview:self.centerImage];
    [headView addSubview:self.nameImage];
    [footerView addSubview:self.messageLabel];
    [footerView addSubview:self.versionlabel];
    
    //设置约束
    [self.centerImage mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.equalTo(headView);
        make.top.equalTo(headView).offset(40);
        make.height.mas_equalTo(90);
        
    }];
    
    [self.nameImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(headView);
        make.top.equalTo(self.centerImage.mas_bottom).offset(10);
        make.height.mas_equalTo(45);
        
    }];
    
    [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.equalTo(footerView);
        make.top.offset(220);
        
    }];
    
    [self.versionlabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.equalTo(footerView);
        make.top.equalTo(self.messageLabel.mas_bottom).offset(20);
        
    }];

}

#pragma mark - tableView数据源方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    cell.textLabel.text = @"用户协议";
    cell.imageView.image = [UIImage imageNamed:@"product_img_icon_xieyi.png"];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    return cell;
    
}

//点击cell的方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
    [SVProgressHUD setMinimumDismissTimeInterval:1.5];
    [SVProgressHUD showSuccessWithStatus:@"打开用户协议!"];
    
}

@end
